package com.zhuyp.spring.boot.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zhuyp.spring.boot.entity.User;
import com.zhuyp.spring.boot.entity.UserExample;
import com.zhuyp.spring.boot.entity.UserExample.Criteria;
import com.zhuyp.spring.boot.mapper.UserMapper;
import com.zhuyp.spring.boot.utils.Common;

@Service
public class UserService extends BaseService<User, UserExample, UserMapper> implements UserMapper {

	@Autowired
	@Override
	public void setMapper(com.zhuyp.spring.boot.mapper.UserMapper m) {
		setBaseMapper(m);
	}

	@Override
	public UserExample createExample(User user) {
		UserExample userExample = new UserExample();
		Criteria criteria = userExample.createCriteria();
		if (user != null) {
			if (!Common.isEmpty(user.getId())) {
				criteria.andIdEqualTo(user.getId());
			}
			if (!Common.isEmpty(user.getName())) {
				criteria.andNameEqualTo(user.getName());
			}
		}
		return userExample;
	}

}
